package net.tv90.bfmccore.util.HUD;

import lk.vexview.api.VexViewAPI;
import lk.vexview.hud.VexTextShow;
import net.tv90.bfmccore.util.vector.Vector2i;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.Collections;
import java.util.Set;

public class TextShow extends Text{

    public String name;
    public int lastTime;
    public VexTextShow textShow;

    public TextShow(Vector2i textPos, String content, double textScale, String name, int lastTime) {
        super(textPos, content, textScale);
        this.name = name;
        this.lastTime = lastTime;
        textShow = new VexTextShow(
                name,
                getTextPos().getX(),
                getTextPos().getY(), 1,
                Collections.singletonList(getContent()), lastTime, getTextScale());
    }

    public void show(Player player) {
        VexViewAPI.sendHUD(player, textShow);
    }
    public void showToPlayers(Set<Player> list) {
        list.forEach(p -> VexViewAPI.sendHUD(p, textShow));
    }
    public void showToAllPlayers() {
        Bukkit.getOnlinePlayers().forEach(p -> VexViewAPI.sendHUD(p, textShow));
    }
}
